﻿using System.Collections.ObjectModel;
using Startup.Base.Commands;
using Startup.MVVM;
using Startup.Shell.Domain;
using Startup.Shell.Domain.FunctionalityContracts;

namespace Startup.Shell.Modules.ClassEditorModule
{
	public class ClassEditorViewModel : ViewModelBase
	{
		private readonly ClassEditorModel _model;

		public ClassEditorViewModel(ClassEditorModel model)
		{
			_model = model;
		}

		public static ClassEditorViewModel Designer
		{
			get
			{
				var classItem = new StartupClass { Name = "Class1" };
				classItem.Properties.Add(new StartupProperty() { Type = "Staring", Name = "Property1"});
				classItem.Properties.Add(new StartupProperty() { Type = "Int", Name = "Property2"});

				var model = new ClassEditorModel(classItem);
				return new ClassEditorViewModel(model);
			}
		}

		public ObservableCollection<StartupProperty> Properties
		{
			get { return _model.ClassItem.Properties; }
		}

		public ObservableCollection<CommandContractBase> FunctionalityContracts
		{
			get { return _model.ClassItem.FunctionalityContracts; }
		}

		public SimpleCommand NewPropertyCommand
		{
			get { return new SimpleCommand(() => _model.ClassItem.Properties.Add(new StartupProperty() {Name = "NewProperty", Type = "Object"} )); }
		}
	}
}
